New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@statsig/client-core

Package Overview
Dependencies
Maintainers
7
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@statsig/client-core

  • 3.12.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
7
Created

What is @statsig/client-core?

@statsig/client-core is a JavaScript library designed to help developers implement feature flags, dynamic configurations, and A/B testing in their applications. It allows for real-time feature management and experimentation, enabling teams to release features safely and measure their impact.

What are @statsig/client-core's main functionalities?

Feature Flags

This code demonstrates how to use @statsig/client-core to check if a feature flag is enabled for a specific user. The `checkGate` method is used to determine the status of a feature flag.

const { StatsigClient } = require('@statsig/client-core');

async function main() {
  const client = new StatsigClient('client-api-key', { userID: 'user123' });
  await client.initializeAsync();

  const isFeatureEnabled = client.checkGate('new_feature');
  console.log('Is new feature enabled:', isFeatureEnabled);
}

main();

Dynamic Configurations

This code shows how to retrieve dynamic configurations using @statsig/client-core. The `getConfig` method fetches configuration values that can be used to customize application behavior without deploying new code.

const { StatsigClient } = require('@statsig/client-core');

async function main() {
  const client = new StatsigClient('client-api-key', { userID: 'user123' });
  await client.initializeAsync();

  const config = client.getConfig('button_color');
  console.log('Button color config:', config.getValue('color', 'defaultColor'));
}

main();

A/B Testing

This example illustrates how to use @statsig/client-core for A/B testing. The `getExperiment` method is used to determine which variant of an experiment a user is assigned to, allowing for controlled testing of different features or configurations.

const { StatsigClient } = require('@statsig/client-core');

async function main() {
  const client = new StatsigClient('client-api-key', { userID: 'user123' });
  await client.initializeAsync();

  const experiment = client.getExperiment('button_test');
  console.log('Experiment variant:', experiment.getValue('variant', 'control'));
}

main();

Other packages similar to @statsig/client-core

FAQs

Package last updated on 18 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc